<?php
/**
 * Image Functions
 */
class Anderles_Image
{
	public $_width = 0;
	public $_height = 0;
	public $_destination = null;
	public $_newName = null;
	
	// только для .jpg
	public function createThumbnail($path, $name, $destination, $_size)
	{
		$this->_destination = $destination;
	if (is_file ( $path . $name )) {
			$size = getimagesize ( $path . $name );
			$src = imagecreatefromjpeg ( $path . $name );
			$this->_width = $size [0];
			$this->_height = $size [1];
			$koe = $this->_width / $_size;
			$thumbHeight = ceil ( $this->_height / $koe );
			$dst = imagecreatetruecolor ( $_size, $thumbHeight );
			imagecopyresampled ( $dst, $src, 0, 0, 0, 0, $_size, $thumbHeight, ImageSX ( $src ), ImageSY ( $src ) );
			imagejpeg ( $dst, $this->_destination . $name, 100 );
		}
		
	}
}